/******************************************************************************
 *Copyright (C) 2024 EternalChip, Inc.(Gmbn) or its affiiates.
 *
 * All Rignts Reserved
 * 
 * @file bsp_led_driver.c
 * 
 * @par dependencies
 * -bsp_led_driver.h
 * 
 * 
 * @author ssm |R&D Dept. |EternalChip 立芯嵌入式
 * 
 * biref Provide the APIs of LEDS and corresponding operations,
 * 
 * Processing flow;
 * 
 * call directly.
 * 
 * @version V1.0 2025-6-5
 * 
 * @note 1 tab == 4 spaces!
 * 
******************************************************************************/

//******************************  Icludes ************************************//

#include "bsp_led_driver.h"

//******************************  Icludes ************************************//

//******************************  Defines ************************************//


/**
 *@brief instantiate the target of bsp_led_driver_t
 *
 * Steps:
 * 1,make the target at a sqecific statues
 * 
 * 
 * @param[0]  self      :
 * 
 * @return led_status_t :The status of runing   
  
**/

led_status_t led_driver_init(bsp_led_driver_t* self)
{
    led_status_t ret=LED_OK;
    if(NULL==self)
    {
#ifdef DEBUG
        DEBUG_OUT("input paras error\r\n");
#endif //DEBUG
        return LED_ERRORPARAMETER;
    }
    self->p_led_opes_inst->pf_led_off();
		uint32_t os_time=0;
		self->p_os_delay_ms->pf_os_delay_ms(&os_time);
		uint32_t time_samp=0;
		self->p_time_base_ms->pf_get_time_ms(&time_samp);
		ret=LED_OK;

    return ret;
}


/**
 *@brief instantiate the target of bsp_led_driver_t
 *
 * Steps:
 * 1,Adding the Core interfaces into traget of bsp_led_driver instance
 * 2,Adding the OS interfaces into traget of bsp_led_driver instance
 * 3,Adding the time_base interfaces into traget of bsp_led_driver instance
 * 
 * 
 * @param[0]  self      :
 * @param[1]  led_ops   :
 * @param[2]  os_delay  :
 * @param[3]  timebase  : 
 * 
 * @return led_status_t :The status of runing   
  
**/

led_status_t led_driver_inst(
                                bsp_led_driver_t * 	    self,
                                led_operations_t *   led_ops,
#ifdef OS_SUPPIRTING
                                os_delay_ms_t    *   os_delay,
#endif //OS_SUPPIRTING																
                                time_base_ms_t   *   timebase
)
{
    led_status_t ret;
#ifdef DEBUG
        DEBUG_OUT("led inst Kick_off\r\n");
#endif //DEBUG
/*********************check the inupt parameters*******************************/
    if(NULL==self     ||
       NULL==led_ops  ||
       NULL==os_delay ||
       NULL==timebase 
                        )
    {
#ifdef DEBUG
        DEBUG_OUT("input paras error\r\n");
#endif //DEBUG
        return LED_ERRORPARAMETER;
    }
/*********************check the reSources ************************************/
    if(INITED==self->is_init)
    {
#ifdef DEBUG
        DEBUG_OUT("LED_ERRORRESOURCE");
#endif //DEBUG
        return LED_ERRORRESOURCE;
    }  
#ifdef DEBUG
        DEBUG_OUT("led_inst_start\r\n");
#endif //DEBUG
/*********************3.adding the interface **********************************/

    self->p_led_opes_inst  =  led_ops;
    self->p_os_delay_ms    =  os_delay;
    self->p_time_base_ms   =  timebase;
/*********************4.init the target ***************************************/
    self->blick_times       =  0;
    self->cycle_time_ms     =  0;
    self->proportion_on_off =  PROPORTION_x_x;  

    ret=led_driver_init(self);
		if(LED_OK!=ret)
		{
#ifdef DEBUG
        DEBUG_OUT("led init error\r\n");
#endif //DEBUG
			self->p_led_opes_inst  =  NULL;
			self->p_os_delay_ms    =  NULL;
			self->p_time_base_ms   =  NULL;
		}
		self->is_init=LED_OK;
		
#ifdef DEBUG
    DEBUG_OUT("led init finished\r\n");
#endif //DEBUG
		return ret;

}


//******************************  Defines ************************************//

//******************************  Declaring **********************************//



//******************************  Declaring **********************************//


